﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Sdms.DataAccess;
using Sdms.Service.Interface;

namespace Sdms.Service.Implementation
{
    //[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    class UserService : IUserService
    {
        private readonly SdmsEntities _context = new SdmsEntities("http://localhost:47175/SdmsDataService.svc");

        #region Implementation of IUserService

        public IEnumerable<string> FindAllUserNames()
        {
            return new HashSet<string>(_context.Users.Where(user => user.DisplayName != null).Select(u => u.DisplayName));
        }

        public User FindUser(int id)
        {
            return _context.Users.Where(user => user.Id == id).First();
        }

        public void CreateUser(User user)
        {
            _context.Users.AddObject(user);
        }

        #endregion
    }
}
